Lifetime of an ipykernel Jupyter kernel

last modified

2023–10–17

Execution always starts with the constructor of the ipykernel.kernelbase.Kernel subclass, and ends with do_shutdown.

Jupyter notebook

Opening a notebook starts the kernel. Closing it leaves it running, shutdown has to be done explicitly.

Both and ▸▸ shut the kernel down and start a new one.

VS Code notebook

Opening a notebook editor starts the kernel, closing it shuts it down.

‘Restart’ shuts the kernel down and starts a new one.

Quarto

Quarto keeps by default one persistent kernel per document / notebook alive, and reuses it for all executions. There is no apparent indication to the kernel that execution has restarted.

This behavior can be avoided via execute: / daemon: false.